import { env } from "../../utils/env";

Component({
  properties: {
    title: {
      type: String,
      value: '填写助力信息',
    },
    showDialog: {
      type: Boolean,
      value: false,
    },
    // c_time: {
    //   type: String,
    //   value: '填写助力信息',
    // },
    // l_num: {
    //   type: Number,
    //   value: 0,
    // },
    // remark: {
    //   type: String,
    //   value: '',
    // },
    // z_code: {
    //   type: String,
    //   value: '',
    // },
    // z_img: {
    //   type: String,
    //   value: '',
    // },
    // z_num: {
    //   type: Number,
    //   value: '',
    // },
    // uid: {
    //   type: Number,
    //   value: null,
    // },
    
  },

  data: {
    c_time: '',
    remark: '',
    z_code: '',
    z_img: '',
    z_num: 0,
    z_uid: null,
    uid: null,
    imgBaseURL: env.imgBaseURL,

  },

  methods: {
    // 显示对话框
    show(e) {
      const { c_time,remark,z_code,z_img,z_num ,uid,z_uid} = e
      this.setData( 
        { 
          showDialog: true ,  
          c_time,
          remark,
          z_code, 
          z_img, 
          z_num, 
          uid, 
          z_uid
        }
      );
    },

    clearStatus(type){
      this.setData( 
        { 
          showDialog: type === 'open' ,  
          c_time: '',
          remark: '',
          z_code: '',
          z_img: '',
          z_num: 0,
          z_uid: null,
          uid: null,
        }
      );
    },

    // 隐藏对话框
    hide() {
      this.clearStatus('hide')
    },

    // 确认
    saveImage() {
      this.triggerEvent('saveImage', {
        z_img: this.data.z_img,
        z_uid: this.data.z_uid,
      });
    },
    // 确认
    copyZCode() {
      this.triggerEvent('copyZCode', {
        z_code: this.data.z_code,
        z_uid: this.data.z_uid,

      });
    },

    // 取消
    onCancel() {
      this.triggerEvent('cancel');
    },

  },
});